import request from '@/utils/request'
import { encrypt } from '@/utils/rsaEncrypt'

export function list(data) {
  return request({
    url: 'retail/store/storeByType',
    method: 'get',
    params: data
  })
}
/** ************************************************************************************************ */
export function add(data) {
  return request({
    url: 'mall/yxSystemStore',
    method: 'post',
    data
  })
}

export function get() {
  return request({
    url: 'mall/yxSystemStore',
    method: 'get'
  })
}

export function getAll() {
  return request({
    url: 'mall/yxSystemStore/all',
    method: 'get'
  })
}

export function getL(data) {
  return request({
    url: 'mall/yxSystemStore/getL',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'mall/yxSystemStore/',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'mall/yxSystemStore',
    method: 'put',
    data
  })
}
export function queryBalace(id) {
  return request({
    url: `retail/store/queryBalace?id=${id}`,
    method: 'get',
    data: id
  })
}

/**
 * 更新用户密码
 * @param {*} user
 * @returns
 */
export function updatePass(user) {
  const data = {
    oldPass: encrypt(user.oldPass),
    newPass: encrypt(user.newPass)
  }
  return request({
    url: 'retail/retail/updatePass/',
    method: 'post',
    data
  })
}
/**
 * 门店提现
 * @param {*} data
 * @returns
 */
export function extract(data) {
  return request({
    url: 'retail/retail/extract',
    method: 'post',
    data
  })
}

export default { getL, add, edit, del, get, getAll, queryBalace }
